Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Creating a dynamic temp-table
Next, look at a few parts of procedure
h-gettemptable.p.The main block creates a dynamic query for the database tables requested (such as Order and Customer). The
createBuffersprocedure creates a dynamic buffer for each of those tables.The
getFieldHandlesprocedure assembles a list of the handles to the fields requested (such as Order.OrderNum).The
createTempTableprocedure creates a dynamic temp-table calledhTT, and addsiCountto it as its first field:
It then walks through the list of database field handles and adds a field to the temp-table like each field:
It then adds an index on
iCount, so that the records remain in the order they were created:
Finally, it prepares the temp-table, which freezes its definition and enables you to add records to it:
Next, the
h-gettemptable.pprocedure populates the temp-table in thepopulateTempTableinternal procedure. HandlehTTBufholds the handle to the temp-table’s default buffer:
The procedure prepares the database query with the
FOR EACHstatement entered in the dialog box, opens it, and retrieves the first record:
For as many rows as there are in the query, or as many rows as you asked for, whichever is less, the procedure creates a temp-table row using the buffer handle:
Because you selected individual fields from possibly multiple tables in the database to add to the temp-table, it doesn’t do a
BUFFER-COPYto move fields from the database records to the newly created temp-table row. Instead, the next block of code uses theBUFFER-FIELDandBUFFER-VALUEattributes on both the database buffer fields and the temp-table buffer fields to move values from one to the other.The procedure then releases each temp-table row, iterates through the query until the
REPEATcondition fails, and then closes the query:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |